package com.swu.pad.analysis.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.swu.pad.analysis.service.AnalysisService;
import com.swu.pad.system.entity.User;

@Controller
@RequestMapping(value = "/analysis")
public class AnalysisController {

	@Autowired
	private AnalysisService analysisService;

	/**
	 * 获取组内雷达图
	 * @param activityId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getGroupRadar")
	public Map<String, Object> getGroupRadar(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getGroupRadar(activityId, user);
	}
	@ResponseBody
	@RequestMapping(value = "/getCourseRadar")
	public Map<String, Object> getCourseRadar(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getCourseRadar(activityId, user);//班级平均
	}

	/**
	 * 获取专注度折线图
	 * @param activityId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getFocusLine")
	public Map<String, Object> getFocusLine(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getFocusLine(activityId, user);
	}

	/**
	 * 获取组内字数饼图
	 * @param activityId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getGroupWordPie")
	public Map<String, Object> getGroupWordPie(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getGroupWordPie(activityId, user);
	}
	@ResponseBody
	@RequestMapping(value = "/getCourseWordPie")
	public Map<String, Object> getCourseWordPie(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getCourseWordPie(activityId, user);//班级平均
	}

	/**
	 * 获取组内版本数柱状图
	 * @param activityId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getGroupVersionBar")
	public Map<String, Object> getGroupVersionBar(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getGroupVersionBar(activityId, user);
	}
	@ResponseBody
	@RequestMapping(value = "/getCourseVersionBar")
	public Map<String, Object> getCourseVersionBar(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getCourseVersionBar(activityId, user);
	}

	/**
	 * 获取pad所有人专注度集合
	 * @param assignmentPadId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getFocus")
	public List getAverageFocusByMission(String activityId, HttpSession session) {
		User user = (User) session.getAttribute("user");
		return analysisService.getPadFocus(activityId, user.getId());
	}
}
